/*
 * Parser.java  1.0 7 Nov, 2013
 */


import java.util.Scanner;

public class Commons {
    public static String getStringWithPrompt(String prompt) {
        Scanner scanner = new Scanner(System.in);
        
        System.out.print(prompt);
        String result = scanner.nextLine().trim();

        return result;
    }

    public static String[] getStringArrayWithPrompt(String prompt) {
        return getStringWithPrompt(prompt).split("\\s+");
    }

    public static int getIntWithPrompt(String prompt) {
        return Integer.parseInt(getStringArrayWithPrompt(prompt)[0]);
    }

    public static int[] getIntArrayWithPrompt(String prompt) {
        String[] inputtedArray = getStringArrayWithPrompt(prompt);
        int[] result = new int[inputtedArray.length];

        for (int i = 0; i < inputtedArray.length; i++) {
            result[i] = Integer.parseInt(inputtedArray[i]);
        }

        return result;
    }

    public static void terminateProgramWithMessage(String message) {
        System.out.println(message);
        System.exit(1);
    }
}
